﻿<template>
    <!--    引入container布局-->
    <el-container class="home-container">
        <el-header>
            <div>
                <img src="../assets/QQ.png" alt/>
                <span>员工信息管理系统</span>
            </div>
            <el-dropdown>
                <el-button type="primary" icon="el-icon-user-solid" size="mini">
                    <span>{{name}}</span><i class="el-icon-arrow-down el-icon--right"></i>
                </el-button>
                <el-dropdown-menu slot="dropdown">
                    <div>
                        <el-button type="warning" @click="update()" > 信息修改</el-button>
                    </div>
                    <div>
                    <el-button type="danger" @click="logout" >安全退出</el-button>
                    </div>

                </el-dropdown-menu>
            </el-dropdown>

        </el-header>
        <!--        主体-->
        <el-container>
            <!--            侧边栏-->
            <el-aside width="200px">
                <el-menu :default-active="$route.path"
                         class="el-menu-vertical-demo"
                         router
                         background-color="#545c64" text-color="#fff" active-text-color="#409eff">
                    <el-submenu index="1" >
                        <template slot="title">
                            <i class="el-icon-location"></i>
                            <span>信息查询</span>
                        </template>
                        <el-menu-item index="/home/department">
                            <span slot="title">部门信息</span>
                        </el-menu-item>
                        <el-menu-item index="/home/worker">
                            <span slot="title">员工信息</span>
                        </el-menu-item>
                        <el-menu-item index="/home/profit">
                            <span slot="title">业绩信息</span>
                        </el-menu-item>
                        <el-menu-item index="/home/task">
                            <span slot="title">任务信息</span>
                        </el-menu-item>
                    </el-submenu>
                    <el-submenu index="2" >
                        <template slot="title">
                            <i class="el-icon-setting"></i>
                            <span>用户中心</span>
                        </template>
                        <el-menu-item  index="/home/message">
                            <span slot="title">用户信息</span>
                        </el-menu-item>
                        <el-menu-item index="/home/salary">
                            <span slot="title">薪资信息</span>
                        </el-menu-item>
                        <el-menu-item index="/home/getAttendance">
                            <span slot="title">今日签到</span>
                        </el-menu-item>
                        <el-submenu index="2-2">
                            <template slot="title">请假管理</template>
                            <el-menu-item index="/home/application">请假申请</el-menu-item>
                            <el-menu-item index="/home/states">假期状态</el-menu-item>
                        </el-submenu>
                    </el-submenu>

                </el-menu>
            </el-aside>
            <!--            主体内容-->
            <el-main>
                <router-view>

                </router-view>
            </el-main>
        </el-container>
    </el-container>
</template>

<script>
    export default {
        data(){
          return{
              name:null
          }
        },
        //onload事件
        created() {
            //回车监听事件
            var _this = this;
            document.onkeydown = function(e) {
                let key = window.event.keyCode;
                if (key == 13) {
                    _this.login();
                }
            }
            //const _this = this
            _this.name=window.sessionStorage.getItem("name")

        },
        methods: {
            //安全退出
            logout() {
                window.sessionStorage.clear();//清除session
                this.$router.push("/login");
            },
            update(){
                this.$router.push("/home/message");
            },
        },

    }
</script>
<style lang="less" scoped>
    .el-header {
        background-color: #373d41;
        display: flex;
        justify-content: space-between; // 左右贴边
        padding-left: 0%; // 左边界
        align-items: center; // 水平
        color: #fff;
        font-size: 20px;

        > div { //左侧div加布局
            display: flex;
            align-items: center;

            span {
                margin-left: 15px;
            }
        }
    }

    .el-aside {
        background-color: #333744;

        .el-menu {
            border-right: none; // 对其右边框
        }
    }

    .el-main {
        background-color: #eaedf1;
    }

    .home-container {
        height: 100%;
    }

    .logo_img {
        width: 20%;
        height: 100%;
    }

    .iconfont {
        margin-right: 10px;
    }

    .toggle-button {
        background-color: #4A5064;
        font-size: 10px;
        line-height: 24px;
        color: #fff;
        text-align: center;
        letter-spacing: 0.2em;
        cursor: pointer; // 显示鼠标指针为：小手
    }
</style>
